home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
DNA_XCMD
/
REVERSEC.C
< prev
Wrap
C/C++ Source or Header
|
1991-09-14
|
2KB
|
49 lines
/* ReverseCompliment.c
A HyperCard XFCN that returns the reverse (backwards) complimented sequence. It
uses the base conversion routine 'BaseComp.c' to map the individual bases.
Molecular Genetics Laboratory, The Salk Institute
Division of Biology & Dept. of Comp. Sci, Washington University
America OnLine: Reece Internet: reece@informatics.wustl.edu
To compile (Think C):
1) Create project with this file, BaseComp.c, MacTraps, ANSI-A4, and HyperXLib.
2) Choose 'Set Project Type╔'. Select type 'Code Resource',
name 'ReverseCompliment', type 'XFCN', and ID '2002'.
3) Select 'Build Code Resource╔" from Project menu.
*/
#include <HyperXCmd.h>
#include "string.h"
#include "BaseComp.h"
#define NIL ((void *) 0)
pascal void main(XCmdPtr paramPtr)
{
Handle ReturnHdl;
register char *i, *j; /* i will point to incoming, j to outgoing */
int len;
/* Get length of incoming sequence */
len = strlen(*paramPtr->params[0]);
/* Allocate space that is as large as the incoming sequence + 1 for '\0'. If
allocation fails, we return a NIL handle. */
if ( (ReturnHdl = (Handle) NewHandle ((long) len + 1)) != NIL )
{
/* Incoming sequence (i) will be read left to right until '\0', and stored
in outgoing sequence (j) from right to left. */
i = *paramPtr->params[0]; /* i points to start of incoming */
j = *ReturnHdl + len; /* and j points to end of outgoing */
*j-- = '\0'; /* null terminate outgoing and decrement j */
for ( ; *i; i++, j--) /* copy sequence in reverse */
*j = BaseCompliment(*i);
}
paramPtr->returnValue = ReturnHdl;
}